#include "opencv/highgui.h"

int _main( int argc, char** argv ) {
  cvNamedWindow( "2_PlayAviVideo", CV_WINDOW_AUTOSIZE );

  // Read the AVI file, all the information is stored in CvCapture structure
  // and the pointer is reset to AVI file's header
  CvCapture* capture = cvCreateFileCapture ( argv[1] );
  IplImage* frame;

  // Once enter into while loop, we are starting read frames
  while(1) {
      // load next frame into memory
      frame = cvQueryFrame( capture );
      if ( !frame ) break;

      // Display the frame inside the window
      cvShowImage( "2_PlayAviVideo", frame );

      // Wait for 33ms
      char c = cvWaitKey(33);

      // If user enter Esc key, exit playing the video
      if ( c == 27 ) break;
  }

  cvReleaseCapture( &capture );
  cvDestroyWindow( "2_PlayAviVideo" );

  return (0);
}
